package licode.unisop.realm.adapter.web;

import licode.unisop.client.utils.PlatformCheck;
import licode.unisop.provider.info.UserIdInfo;
import licode.unisop.provider.vo.SiIdentitySet;
import licode.unisop.realm.client.api.SiIdentityQueryService;
import licode.unisop.unilite.result.UniReturnResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 适配RESTFUL接口访问，处理领域的操作
 *
 * @author WR
 */
@RestController
@UniReturnResult
@RequestMapping("/user-api/v1/internal/identity/query")
public class IdentityQueryController {
    @Resource
    private HttpServletRequest request;

    @Resource
    private PlatformCheck platformCheck;

    @Resource
    private SiIdentityQueryService siIdentityQueryService;

    @PostMapping("/auth")
    public SiIdentitySet findIdentity(@RequestBody UserIdInfo idFind) {
        platformCheck.checkModalToken(request);
        return siIdentityQueryService.findIdentity(idFind);
    }
}
